<?php
class ControllerArticleIndex extends FrontController {
	public function index() {
		$article_id = G('article_id', 0);

		M('article/article');
		$article = $this->model_article_article->getArticle($article_id);

		$this->model_article_article->updateHitsOne($article_id);
		
		if (!$article) {
			return $this->forward('error/not_found');
		}
		
		$this->data['breadcrumbs'][] = array(
				'text'      => $this->_['heading_title'],
				'href'      => U('article/category'),
				'separator' => $this->_['text_separator']
		);
		
		$this->data['breadcrumbs'][] = array(
				'text'      => $article['category'],
				'href'      => U('article/category', 'category_id=' . $article['category_id']),
				'separator' => $this->_['text_separator']
		);
		$this->document->addStyle('themes/' . C('config_template') . '/stylesheet/article.css');
		$this->document->setTitle($article['title'] . ' - ' . $this->_['heading_title']);
		$this->document->setKeywords($article['meta_keywords']);
		$this->document->setDescription($article['meta_description']);
		
		$article['content'] = html_entity_decode($article['content'], ENT_QUOTES, 'UTF-8');
		$this->data['article'] = $article;		
		
		$this->display("article/article.tpl");
	}
}